import React, {PropTypes} from 'react';
import {Link} from 'dva/router';
import {Form, Input, Modal, Icon, message, Spin, Select, Button, Row, Col} from 'antd';
import classnames from 'classnames';
import moment from 'moment';
import CommonCodeInput from '../Common/CommonCodeInput';

const FormItem = Form.Item;
const Option = Select.Option;
const OptGroup = Select.OptGroup;

const formItemLayout = {
  labelCol: {
    span: 4,
  },
  wrapperCol: {
    span: 18,
  },
};

const OrderModal = ({
  title,
  modalVisible,
  item,
  btnLoading,
  modalLoading,
  selectData,
  onOk,
  onOkAndAdd,
  onAddType,
  onCancel,
  form: {
    getFieldDecorator,
    validateFields,
    getFieldsValue,
    resetFields,
    setFieldsValue,
  },
}) => {

  function handleOk(callback) {
    validateFields((errors) => {
//            if (errors) {
//                return;
//            }
      const data = getFieldsValue();
//						if(item.tech_id) {
//                data.tech_id = item.tech_id;
//            }

      callback(data, () => {
        resetFields();
      });
    });
  }

  function handleCancel() {
    resetFields();
    onCancel();
  }

  const modalOpts = {
    title,
    visible: modalVisible,
    width: 600,
    maskClosable: false,
    onCancel: handleCancel,
  };

  const data = ['1', '2', '3'];

  const loop = data => data.map((value, index) => <Option key={index} value={value}>{value}</Option>);

  return (
    <Modal {...modalOpts}>
      <Form layout="horizontal">
        <FormItem label="Count" {...formItemLayout}>
          {getFieldDecorator("count", {rules: [{required: true, message: '请填写count'}]})
          (<Input
            type="number"
            placeholder="第几个">
          </Input>)}
        </FormItem>
        <FormItem label="Name" {...formItemLayout}>
          {getFieldDecorator("name",
            {initialValue: '订单详情', rules: [{required: true, message: '请填写name'}]})
          (<Input
            placeholder="姓名">
          </Input>)}
        </FormItem>
        <FormItem label="Age" {...formItemLayout}>
          {getFieldDecorator("age", {rules: [{required: true, message: '请填写age'}]})
          (<Input
            placeholder="年龄"/>)}
        </FormItem>
        <FormItem label="Address" {...formItemLayout}>
          {getFieldDecorator("address", {rules: [{required: true, message: '请填写address'}]})
          (<Input
            placeholder="住址"/>)}
        </FormItem>
        <FormItem label="Description" {...formItemLayout}>
          {getFieldDecorator("description", {rules: [{required: true, message: '请填写description'}]})
          (<Input
            placeholder="描述"/>)}
        </FormItem>
      </Form>
    </Modal>
  );
};

OrderModal.propTypes = {
  title: PropTypes.any,
  visible: PropTypes.any,
  item: PropTypes.object,
  btnLoading: PropTypes.any,
  modalLoading: PropTypes.any,
  form: PropTypes.object,
  onOk: PropTypes.func,
};

export default Form.create()(OrderModal);
